package com.bw.module_merchant.activity

import android.os.Bundle
import androidx.activity.viewModels
import com.blankj.utilcode.util.SPUtils



import com.bw.module_merchant.vm.EnterpriseViewModel
import com.example.lib_common.view.view.BaseMvvmActivity
import com.example.module_merchant.R
import com.example.module_merchant.databinding.ActivityEnterpriseDetailBinding


import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class EnterpriseDetailActivity : BaseMvvmActivity<ActivityEnterpriseDetailBinding>() {

    private val viewModel : EnterpriseViewModel by viewModels()

    override fun getLayoutId(): Int = R.layout.activity_enterprise_detail

    override fun initViews() {


        val id = SPUtils.getInstance().getInt("enterpriseId")

        viewModel.getEnterpriseDetail(id)
        binding.enterpriseBack.setOnClickListener {
            finish()
        }
        viewModel.mSuccessLiveData.observe(this){
            if (it.data[0].listed){ binding.enterpriseDetailListed.setText("是")
            }else{
                binding.enterpriseDetailListed.setText("否")
            }
            binding.enterpriseDetailName.setText(it.data[0].name)
            binding.enterpriseDetailType.setText(it.data[0].industryType)
            binding.enterpriseDetailAddress.setText(it.data[0].address)
            binding.enterpriseDetailStockCode.setText(it.data[0].stockCode)
            binding.enterpriseDetailStockName.setText(it.data[0].stockName)
            binding.enterpriseDetailContactInfo.setText(it.data[0].contactInfo)
            binding.enterpriseDetailLegalRepresentative.setText(it.data[0].legalRepresentative)
            binding.enterpriseDetailStatus.setText(it.data[0].status)
        }


    }

    override fun getActivityState(state: Bundle) {
        TODO("Not yet implemented")
    }

    override fun saveActivityState(outState: Bundle) {
        TODO("Not yet implemented")
    }

}